unit unit_OutputBoxes;

interface
uses
  Forms, StdCtrls, Graphics;

const
  TOP_SHIFT = 16;
  LEFT_SHIFT = 8;
  D_HEIGHT = TOP_SHIFT + TOP_SHIFT div 2;
  D_WIDTH = LEFT_SHIFT * 2;

type
  TTextOutputBox = class
  private
    parent: TForm;
    group: TGroupBox;
    text: TLabel;
    height, width: integer;
    top, left: integer;

    procedure protectedCreate(parent: TForm; top, left, height, width: integer);
  public
    constructor Create(parent: TForm; top, left, height, width: integer);  overload;
    constructor Create(parent: TForm; top, left, width: integer; title: string; text: string); overload;
    constructor Create(parent: TForm; top, left, height, width: integer;
                                        title: string; text: string); overload;

  end;

implementation

procedure TTextOutputBox.protectedCreate(parent: TForm;top, left, height, width: integer);
begin
  Self.parent := parent;
  group := TGroupBox.Create(parent);
  text := TLabel.Create(parent);

  group.Parent := parent;
  group.Caption := '';
  group.Top := top;
  group.Left := left;
  group.Height := height;
  group.Width := width;

  text.Parent := group;
  text.Caption := '';
  text.Top := top + TOP_SHIFT;
  text.Left := text.Left + LEFT_SHIFT;
  text.Height := height - D_HEIGHT;
  text.Width := width - D_WIDTH;
end;

constructor TTextOutputBox.Create(parent: TForm; top, left, height, width: integer);
begin
  Self.protectedCreate(parent, top, left, height, width);
end;

constructor TTextOutputBox.Create(parent: TForm; top, left, width: integer; title: string; text: string);
begin
  Self.protectedCreate(parent, top, left, 0, width);
  group.Caption := title;
  Self.text.Caption := text;
  Self.group.Height := Self.text.Height + D_HEIGHT;
end;

constructor TTextOutputBox.Create(parent: TForm; top, left, height, width: integer;
                                                  title: string; text: string);
begin
  Self.protectedCreate(parent, top, left, height, width);
  group.Caption := title;
  Self.text.Caption := text;
end;

end.
